//api路由
//生产调度>风险调度api
//勾选和确认按钮后端逻辑没做

var models = require('../db');
var express = require('express');
var router = express.Router();
var mysql = require('mysql');
// 连接数据库
var conn = mysql.createConnection(models.mysql);
//model.mysql储存连接信息，位于/server/db.js
//conn.connect();
conn.connect((err) => {
    if (err) {
      console.error('Database connection failed:', err.stack);
      return;
    }
    console.log('Connected to database.');
  });

//确认人员api
  router.get('/query1',(req,res)=>{
    conn.query('select * from dispatch_risk_peopleconfirm',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//确认站位信息api
router.get('/query2',(req,res)=>{
    conn.query('select * from dispatch_risk_positionconfirm',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//确认进度api
router.get('/query3',(req,res)=>{
    conn.query('select * from dispatch_risk_assembly_progress',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//原计划api
router.get('/query4',(req,res)=>{
    conn.query('select * from dispatch_risk_original_plan',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//风险事件api
router.get('/query5',(req,res)=>{
    conn.query('select * from dispatch_risk_things',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//选择调度范围
//主计划表
router.get('/query6',(req,res)=>{
    conn.query('select * from dispatch_risk_mainplan',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
//季/月计划表
router.get('/query7',(req,res)=>{
    conn.query('select * from dispatch_risk_schedule',function(err,row){
        if(err){
             console.log(err)            
        }
        let data = JSON.stringify(row)
        res.end(data)
    })
});
module.exports = router;

